Skip to content

Conversation

@mergify
Copy link

@mergify mergify bot commented Oct 23, 2025

Why

Publishing a log message to an exchange might trigger other messages to be logged. This caused two issues:

  1. the exchange logger re-entering itself in an infinite loop
  2. if the message is logged from a gen_server-like process, like a Ra server, that is involved in the publishing code path, the process might call itself, leading to a blocked situation

How

The first issue is fixed with a variable stored in the process dictionary by the log/2 function. This way, the function can check if it is called from itself because the first incantation stored a variable there.

The second issue is fixed by publishing the message asynchronously from a separate process. This is ok because we don't care if the publish was successful or not. We re-use the process that was started initially to declare the exchange.

Fixes #14069.


This is an automatic backport of pull request #14796 done by Mergify.

[Why]
Publishing a log message to an exchange might trigger other messages to
be logged. This caused two issues:
1. the exchange logger re-entering itself in an infinite loop
2. if the message is logged from a gen_server-like process, like a Ra
   server, that is involved in the publishing code path, the process
   might call itself, leading to a blocked situation

[How]
The first issue is fixed with a variable stored in the process
dictionary by the `log/2` function. This way, the function can check if
it is called from itself because the first incantation stored a variable
there.

The second issue is fixed by publishing the message asynchronously from
a separate process. This is ok because we don't care if the publish was
successful or not. We re-use the process that was started initially to
declare the exchange.

Fixes #14069.

(cherry picked from commit 7cc0aa9)
[Why]
It makes debugging easier, especially now that this process does more
than the initial setup: it acts as the actual publisher of the log
messages.

(cherry picked from commit 73a41cc)
@michaelklishin michaelklishin added this to the 4.2.0 milestone Oct 23, 2025
@michaelklishin michaelklishin merged commit 7a6b941 into v4.2.x Oct 23, 2025
576 of 577 checks passed
@michaelklishin michaelklishin deleted the mergify/bp/v4.2.x/pr-14796 branch October 23, 2025 19:40
michaelklishin added a commit that referenced this pull request Oct 31, 2025
For 4.1.6: rabbit_logger_exchange_h: Do not re-enter itself (backport #14796) (backport #14804)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants